#ifndef CPU_CMP_H
#define CPU_CMP_H

#include "types.h"

void CPU_Cmp(struct Agent_Var* agent)
{
    struct DataEntry* op1 = readDataEntry(agent);
    struct DataEntry* op2 = readDataEntry(agent);

    switch(op1->type)
    {
        case DT_BYTE:
        {
            t1B val1 = GETE(op1,t1B);
            t1B val2 = GETE(op2,t1B);

            if(val1 == val2) agent->condition = CM_EQUAL;
            else if(val1 < val2)
            {
                agent->condition = CM_LOWER;
            }
            else
            {
                agent->condition = CM_GREATER;
            }
            break;
        }
        case DT_UINT16:
        {
            uint16 val1 = GETE(op1,uint16);
            uint16 val2 = GETE(op2,uint16);

            if(val1 == val2) agent->condition = CM_EQUAL;
            else if(val1 < val2)
            {
                agent->condition = CM_LOWER;
            }
            else
            {
                agent->condition = CM_GREATER;
            }

            break;
        }
        case DT_INT16:
        {
            int16 val1 = GETE(op1,int16);
            int16 val2 = GETE(op2,int16);

            if(val1 == val2) agent->condition = CM_EQUAL;
            else if(val1 < val2)
            {
                agent->condition = CM_LOWER;
            }
            else
            {
                agent->condition = CM_GREATER;
            }
            break;
        }
        default:
            agent->condition = 0;
            break;

    }
}

#endif



